import request from 'utils/request'

/**
 * 获取所有频道
 * @param {*} data
 * @returns
 */
export function getChannelsAPI() {
  return request({
    url: '/channels',
  })
}

/**
 * 根据条件查询文章
 * @returns
 */
export function getArticleAPI(params) {
  return request({
    url: '/mp/articles',
    params,
  })
}

/**
 * 删除文章
 * @param {*} target
 * @returns
 */
export function delArticleByIdAPI(target) {
  return request({
    url: '/mp/articles/' + target,
    method: 'delete',
  })
}

/**
 * 获取文章详情
 * @param {*} target
 * @returns
 */
export function getArticleDetailByIdAPI(target) {
  return request({
    url: '/mp/articles/' + target,
    method: 'get',
  })
}

/**
 * 发布文章 存入草稿
 * @param {*} target
 * @returns
 */
export function pubArticleIdAPI(data, params) {
  return request({
    url: '/mp/articles',
    method: 'post',
    params,
    data,
  })
}

/**
 * 编辑文章 存入草稿
 * @param {*} data
 * @param {*} params
 * @returns
 */
export function editArticleIdAPI(id, params, data) {
  return request({
    url: '/mp/articles/' + id,
    method: 'put',
    params,
    data,
  })
}
